package com.etc.dao;

import com.etc.entity.Blog;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 定义接口
 */
public interface BlogMapper_bak {
    /**
     * 根据id查询blog
     *
     * @param id
     * @return
     * @Results介绍: 完成表中的列名和实体类属性进行关联映射:   String id() default "";
     */
    @Results(id = "blogResult", value = {
            @Result(property = "id", column = "id", id = true),
            @Result(property = "title", column = "blogtitle"),
            @Result(property = "content", column = "content")
    })
    @Select("select * from blog where id = #{id}")
    public Blog selectBlog(int id);


    /**
     * 增加
     *
     * @param blog
     * @return
     */
    @Insert("insert into blog values(#{id},#{title},#{content})")
    public int addBlog(Blog blog);

    /**
     * 修改
     *
     * @param blog
     * @return
     */
    @Update("update  blog set title=#{title}, content = #{content} where id=#{id}")
    public int updateBlog(Blog blog);

    /**
     * 物理删除
     *
     * @param id
     * @return
     */
    @Delete("delete from blog where id=#{id}")
    public int deleteBlog(int id);


    /**
     * ResultMap 可以引用一个已经定义好的@Result
     * @param keywords
     * @param start
     * @param pageSize
     * @return
     */
    @ResultMap(value="blogResult")
    @Select("select * from blog where blogtitle like #{keywords} limit #{start},#{pageSize}")
    public List<Blog> selectBlogByPage(@Param("keywords") String keywords, @Param("start") int start, @Param("pageSize") int pageSize);
}
